home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
win
/
pascal
/
alrmtpw.exe
/
ALARGBL.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-09-10
|
7KB
|
227 lines
{ File: AlarGbl.pas }
{ Created: Mon Sep 09 00:25:27 1991 }
{ Description: unit AlarGbl - Definitions of external data identifiers }
{ used in Alarm and dialog transfer record types }
{{ STARTBLOCK File Version Information (REGENERATE) }
{ Regenerated: Mon Sep 09 00:25:27 1991 }
{ Skeleton by: Winpro/3, a product from Louis J. Cutrona, Jr. }
{ tpw.skl version 0.05 }
{{ ENDBLOCK }
unit AlarGbl ;
interface
uses
WinTypes,
WinProcs,
Strings,
WObjects,
StdWnds,
AlarRC ;
const
{{ STARTBLOCK Defines for preloaded stringtable strings (REGENERATE) }
{ ID assigned to first string }
IDS_FIRSTSTRING = 256 ;
{ Count of string identifiers to be read in at initialization }
CINITSTRINGS = 1 ;
{ Total characters in initial strings (including null terminators) }
CCHINITSTRINGS = 21 ;
{ Maximum length of a stringtable string }
cchMaxRsrcString = 256 ;
{{ ENDBLOCK }
{ Default if no time specified in WIN.INI }
gbl_pszDefault: PChar = '9101011200N' ;
{{ STARTBLOCK Transfer buffer record types for dialog controls (REGENERATE) }
{-----------------------------------------------------------------------------}
{{ STARTBLOCK Dialog dlg_SetAlarmTime data transfer buffer record (PRESERVE) }
type
rtdlg_SetAlarmTimeTransfer = record
szET_MONTH: array[0..2] of Char ; { Edittext }
szET_DAY: array[0..2] of Char ; { Edittext }
szET_YEAR: array[0..2] of Char ; { Edittext }
szET_HOUR: array[0..2] of Char ; { Edittext }
szET_MINUTE: array[0..2] of Char ; { Edittext }
szEM_MESSAGE: array[0..255] of Char ; { Edittext }
end ;
{{ ENDBLOCK }
{-----------------------------------------------------------------------------}
{{ STARTBLOCK Dialog dlg_AboutAlarm data transfer buffer record (REGENERATE) }
type
rtdlg_AboutAlarmTransfer = record
end ;
{{ ENDBLOCK }
{----------------------------------------------------------------------------- }
var
{ Dialog data transfer buffers for dialogs used in Alarm }
{ These are initialized at the end of this unit. }
dlg_SetAlarmTimeTransferBuf: rtdlg_SetAlarmTimeTransfer ;
dlg_AboutAlarmTransferBuf: rtdlg_AboutAlarmTransfer ;
{{ ENDBLOCK }
type
TRsrcStrings = object
hStrings: THandle ;
pszStrings: array [0..CINITSTRINGS-1] of PChar ;
szRsrcStringBuf: array[0..cchMaxRsrcString] of Char ;
{Nothing to do for initialization, so no constructor}
{Preload specified string table strings}
procedure Preload( hInstance: THandle ) ;
{Access preloaded string}
function psz( n: Word ): PChar ;
{Access non-preloaded string}
function pszLoad( n: Word; pszBuf: PChar ): PChar ;
end ;
var
gbl_pRsrcStrings: ^TRsrcStrings ;
{ To obtain a PChar to the preloaded string whose id is MYSTRING: }
{ gbl_pRsrcStrings^.psz( MYSTRING ) ; }
{ To obtain a PChar to a non-preloaded string whose id is MYSTRING: }
{ gbl_pRsrcStrings^.pszLoad( MYSTRING, nil ) ; }
{ To load a non-preloaded string whose id is MYSTRING into a buffer }
{ identified by pszBuf of type PChar: }
{ gbl_pRsrcStrings^.pszLoad( MYSTRING, pszBuf ) ; }
gbl_cAlarmSet: Char ; {Y means set; N means not set}
{ When the alarm should go off }
gbl_wYearAlarm: Word ;
gbl_wMonthAlarm: Word ;
gbl_wDayAlarm: Word ;
gbl_wHourAlarm: Word ;
gbl_wMinuteAlarm: Word ;
{ What time it is now }
gbl_wYearNow: Word ;
gbl_wMonthNow: Word ;
gbl_wDayNow: Word ;
gbl_wHourNow: Word ;
gbl_wMinuteNow: Word ;
implementation
procedure TRsrcStrings.Preload( hInstance: THandle ) ;
var
pch: PChar ;
cchRemaining: Integer ;
i: Integer ;
cch: Integer ;
begin
cchRemaining := CCHINITSTRINGS ;
hStrings := LocalAlloc( lmem_Fixed, cchRemaining ) ;
if hStrings <> 0 then
begin
pch := PChar( Ptr( Seg( pch ), hStrings ) ) ;
i := IDS_FIRSTSTRING ;
while i < IDS_FIRSTSTRING + CINITSTRINGS do
begin
if cchRemaining > 0 then
begin
cch := 1 + LoadString( hInstance, i, pch, cchRemaining ) ;
pszStrings[ i - IDS_FIRSTSTRING ] := pch ;
pch := pch + cch ;
cchRemaining := cchRemaining - cch ;
end ;
i := i + 1 ;
end ;
end
else { Allocation failed }
end ;
function TRsrcStrings.psz( n: Word ): PChar ;
begin
psz := pszStrings[ n - IDS_FIRSTSTRING ] ;
end ;
{Load a string from the resource file.}
{ pszBuf points to the buffer to receive the string. }
{ If pszBuf is null, the string will be placed in a }
{ reusable buffer. }
{ It is the caller's responsibility to ensure that }
{ the string will not overrun the buffer. }
{ Returns a pointer to the loaded string. }
function TRsrcStrings.pszLoad( n: Word; pszBuf: PChar ): PChar ;
begin
if pszBuf = nil then
pszBuf := @szRsrcStringBuf ;
LoadString( hInstance, n, pszBuf, cchMaxRsrcString ) ;
pszLoad := pszBuf ;
end ;
{ Helper routine for initializing list boxes and combo boxes }
procedure LoadBoxStrings( pArray: PCollection; wFrom, wTo: Word ) ;
var
i: Word ;
begin
for i := wFrom to wTo do
begin
pArray^.Insert( StrNew( gbl_pRsrcStrings^.pszLoad( i, PChar(nil) ) ) ) ;
end ;
end ;
{ Unit AlarGbl initialization. }
begin
{ Create string table resource manager object }
{ No special initialization required }
New( gbl_pRsrcStrings ) ;
{ Initialize alarm state }
gbl_cAlarmSet := 'N' ;
{ Initialize dialog data transfer buffers }
{---------------------------------------------------------------------------}
{{ STARTBLOCK Initialize transfer buffer for Dialog dlg_SetAlarmTime (REGENERATE) }
with dlg_SetAlarmTimeTransferBuf do
begin
StrCopy( szET_MONTH, '' ) ; { Edittext }
StrCopy( szET_DAY, '' ) ; { Edittext }
StrCopy( szET_YEAR, '' ) ; { Edittext }
StrCopy( szET_HOUR, '' ) ; { Edittext }
StrCopy( szET_MINUTE, '' ) ; { Edittext }
StrCopy( szEM_MESSAGE, '' ) ; { Edittext }
end ;
{{ ENDBLOCK }
{---------------------------------------------------------------------------}
{{ STARTBLOCK Initialize transfer buffer for Dialog dlg_AboutAlarm (REGENERATE) }
with dlg_AboutAlarmTransferBuf do
begin
end ;
{{ ENDBLOCK }
{----------------------------------------------------------------------------- }
end.
{ E N D O F F I L E AlarGbl }